package com.api.gbhg.luoao.utils;


import weaver.conn.RecordSet;
import weaver.general.BaseBean;

import java.util.Map;

public class ProcesscontentUtils {
    private static String BZ18Workflowid  = "";
    private static String tablename = "";
    static {
        BZ18Workflowid  = new BaseBean().getPropValue("FormationWorkflowid","BZ18Workflowid");
        RecordSet rs = new RecordSet();
        rs.execute("select workflow_bill.tablename from workflow_base right join workflow_bill on workflow_base.formid = workflow_bill.id where workflow_base.id="+BZ18Workflowid);
        rs.next();
        tablename = rs.getString("tablename");
    }
    /**
     * 查询主表
     * @param param
     * @return
     */
    public static RecordSet getPrimarytable(Map<String,Object> param){
        RecordSet recordSet  = new RecordSet();
        recordSet.executeQuery("select * from  " +tablename+
                " where requestId = "+param.getOrDefault("requestId",""));
        return  recordSet;

    }

    /**
     * 查询明细表1
     * @param mainid
     * @return
     */
    public static RecordSet getDetail1(String mainid){
        RecordSet rs = new RecordSet();
        rs.executeQuery("select * from "+tablename+"_dt1 where mainid ="+mainid);
        return  rs;
    }

    /**
     * 查询明细表2
     * @param mainid
     * @return
     */
    public static RecordSet getDetail2(String mainid){
        RecordSet rs = new RecordSet();
        rs.executeQuery("select * from "+tablename+"_dt2 where mainid ="+mainid);
        return  rs;
    }

    /**
     * 查询明细表3
     * @param mainid
     * @return
     */
    public static RecordSet getDetail3(String mainid){
        RecordSet rs = new RecordSet();
        rs.executeQuery("select * from "+tablename+"_dt3 where mainid ="+mainid);
        return  rs;
    }

    public static String getsubjectname(String id){
        RecordSet set = new RecordSet();
        set.executeQuery("select kmc from uf_jjzcflkmk where id ="+id);
        set.next();
        return set.getStringNoTrim("kmc");

    }

    public static String getAttributes(String fromname,String id){
        RecordSet rs = new RecordSet();
        rs.executeQuery("select wf_si.selectvalue,wf_si.selectname from workflow_billfield wf_bf right join workflow_selectitem wf_si on wf_bf.id = wf_si.fieldid \n" +
                "where wf_bf.fieldname = '"+fromname+"' and wf_si.selectvalue = "+id);
        rs.next();
        return  rs.getStringNoTrim("selectname");
    }

}
